package com.mifengkong.greendao;


import com.mifengkong.frtools.app.FRApplication;
import com.mifengkong.greendao.generator.DaoMaster;
import com.mifengkong.greendao.generator.DaoSession;

/**
 *
 */
public class GreenDaoManager {

    private DaoMaster.DevOpenHelper devOpenHelper;
    private DaoMaster daoMaster;
    private DaoSession daoSession;

    public GreenDaoManager(String dbName) {
        if (devOpenHelper == null || daoMaster == null || daoSession == null) {
            devOpenHelper = new DaoMaster.DevOpenHelper(FRApplication.getInstance(), dbName, null);
            daoMaster = new DaoMaster(devOpenHelper.getWritableDb());
            daoSession = daoMaster.newSession();
        }
    }

    public DaoMaster.DevOpenHelper getDevOpenHelper() {
        return devOpenHelper;
    }

    public DaoMaster getDaoMaster() {
        return daoMaster;
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }
}